package com.csu.express.service.impl;

import java.util.Date;
import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.csu.express.dao.OrderCommentsMapper;
import com.csu.express.pojo.OrderCommentsPojo;
import com.csu.express.service.OrderCommentsService;

@Service
public class OrderCommentsServiceImpl implements OrderCommentsService
{
    private static final Logger logger = Logger.getLogger(OrderCommentsServiceImpl.class);

    @Autowired
    private OrderCommentsMapper orderCommentsMapper;

    @Override
    public int addOrderComments(OrderCommentsPojo orderCommentsPojo)
    {
        // 参数校验
        if (orderCommentsPojo == null)
        {
            logger.error("订单评价对象为空");
            return 0;
        }
        else if (orderCommentsPojo.getOrderId() == null || "".equals(orderCommentsPojo.getOrderId()))
        {
            logger.error("订单流水号为空");
            return 0;
        }

        orderCommentsPojo.setCreateTime(new Date());
        orderCommentsMapper.add(orderCommentsPojo);
        return 1;
    }

    @Override
    public List<OrderCommentsPojo> getCommentListByCellPhone(String cellPhone)
    {
        return orderCommentsMapper.getCommentListByCellPhone(cellPhone);
    }

    @Override
    public OrderCommentsPojo getCommentsByOrderId(String orderId)
    {
        return orderCommentsMapper.getCommentsByOrderId(orderId);
    }

}
